package com.csnf.order.controller;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.csnf.order.properties.OrderProperties;
import com.csnf.order.service.OrderService;
import com.csnf.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrderService orderService;

    @Autowired
    OrderProperties orderProperties;

    @RequestMapping("/config")
    public String config(){
        return orderProperties.getTimeout() + "====" + orderProperties.getUrl();
    }

//    @SentinelResource("createOrder")
    @RequestMapping("/createOrder")
    public Order createOrder(String userName, Integer productId, Integer count){
        return orderService.createOrder(userName, productId, count);
    }

    @RequestMapping("/getEitherData")
    public String getEitherData(@RequestHeader String token, @RequestParam String name){
        return "token:" + token +" ========== "+ "name:" + name;
    }

}
